package com.tju.shortlink.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tju.shortlink.admin.common.convention.result.Result;
import com.tju.shortlink.admin.remote.ShortLinkActualRemoteService;
import com.tju.shortlink.admin.remote.dto.req.RecycleBinRecoverReqDTO;
import com.tju.shortlink.admin.remote.dto.req.RecycleBinRemoveReqDTO;
import com.tju.shortlink.admin.remote.dto.req.RecycleBinSaveReqDTO;
import com.tju.shortlink.admin.remote.dto.req.ShortLinkRecycleBinPageReqDTO;
import com.tju.shortlink.admin.remote.dto.resp.ShortLinkPageRespDTO;
import com.tju.shortlink.admin.service.RecycleBinService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController(value = "recycleBinControllerByAdmin")
@RequiredArgsConstructor
@RequestMapping("/api/short-link/admin/v1/recycle-bin")
public class RecycleBinController {

    private final RecycleBinService recycleBinService;
    private final ShortLinkActualRemoteService shortLinkActualRemoteService;

    /**
     * 保存回收站
     */
    @PostMapping("save")
    public Result<Void> saveRecycleBin(@RequestBody RecycleBinSaveReqDTO requestParam) {
        return shortLinkActualRemoteService.saveRecycleBin(requestParam);
    }

    /**
     * 分页查询回收站短链接
     */
    @GetMapping("page")
    public Result<Page<ShortLinkPageRespDTO>> pageShortLink(ShortLinkRecycleBinPageReqDTO requestParam) {
        return recycleBinService.pageRecycleBinShortLink(requestParam);
    }

    /**
     * 恢复短链接
     */
    @PostMapping("recover")
    public Result<Void> recoverRecycleBin(@RequestBody RecycleBinRecoverReqDTO requestParam) {
        return shortLinkActualRemoteService.recoverRecycleBin(requestParam);
    }

    /**
     * 移除短链接
     */
    @PostMapping("remove")
    public Result<Void> removeRecycleBin(@RequestBody RecycleBinRemoveReqDTO requestParam) {
        return shortLinkActualRemoteService.removeRecycleBin(requestParam);
    }
}